<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /**
       * @param {number} n
       * @return {number}
       *
       * f(n):爬n阶有多少种方法
       * f(n) = f(n-1) + f(n-2) 最后一步爬一阶或者2阶
       * f(0) = 1  f(1) = 1
       */
      var climbStairs = function (n) {
        let step = [];
        step[0] = 1;
        step[1] = 1;
        for (let i = 2; i <= n; i++) {
          step[i] = step[i - 1] + step[i - 2];
        }
        return step[n];
      };
    </script>
  </body>
</html>
